package com.zhangc.blog.base;

import java.util.Locale;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

/**
 * 功能描述:<br>
 *
 * @author wx:fdzhangc
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
@Component
public class LanguageUtils {
    private static String language;
    private static String country;

    public static void setLanguage(String language) {
        LanguageUtils.language = language;
        LanguageUtils.country = getCountry();
    }

    private static String getCountry() {
        return "en".equals(language) ? "US" : "CN";
    }

    public static Locale getLocale() {
        if (StringUtils.isAnyBlank(language, country)) {
            return Locale.SIMPLIFIED_CHINESE;
        }
        return new Locale(language, country);
    }

    public static void main(String[] args) {
        //十进制转成二进制
        //System.out.println(Integer.toBinaryString(7));

        StringBuffer stringBuffer = new StringBuffer("0101");
        System.out.println(stringBuffer.reverse().toString());

        //二进制转十进制
        System.out.println(Integer.valueOf("0101", 2));
    }
}
